<fieldset style="background:#ffffff; border-width:thin; border-style:solid; padding:10px; border-color:#CCCCCC;">
<legend style="font-size:1.0em; font-weight: bold;">Maklumat Asas </legend>

<table class="classBackground" border="0" cellpadding="2" cellspacing="1" width="100%">
  <tbody>
    <tr>
      <td class="classRowLabel" align="left" valign="top" width="10"><span style="color:red;">*</span></td>
      <td width="27%" height="20" align="left" valign="top" class="classRowLabel"><strong>Kod Institusi</strong></td>
      <td width="30" align="center" valign="top" class="classRowLabel"><span style="font-weight:bold">:</span></td>
      <td class="classRow"><input name="master_institusi[kod]" id="kod" value="<?=$institusi->kod?>" onblur="" onchange="" onfocus="" onselect="" maxlength="10" size="50" type="text" />      </td>
    </tr>
    <tr>
      <td class="classRowLabel" align="left" valign="top" width="10"><span style="color:red;">*</span></td>
      <td width="27%" height="20" align="left" valign="top" class="classRowLabel"><strong>Nama Institusi</strong></td>
      <td width="30" align="center" valign="top" class="classRowLabel"><span style="font-weight:bold">:</span></td>
      <td class="classRow"><input name="master_institusi[nama]" id="nama" value="<?=$institusi->nama?>" onblur="" onchange="" onfocus="" onselect="" maxlength="100" size="50" type="text" />      </td>
    </tr>
    <tr>
      <td class="classRowLabel" align="left" valign="top" width="10"><span style="color:red;">*</span></td>
      <td width="27%" height="20" align="left" valign="top" class="classRowLabel"><strong>Alamat</strong></td>
      <td width="30" align="center" valign="top" class="classRowLabel"><span style="font-weight:bold">:</span></td>
      <td class="classRow"><textarea name="master_institusi[alamat]" id="alamat" onblur="" onchange="" onfocus="" onselect="" rows="5" cols="40"><?=$institusi->alamat?></textarea>      </td>
    </tr>

    <tr>
      <td class="classRowLabel" align="left" valign="top" width="10"><span style="color:red;">*</span></td>
      <td width="27%" height="20" align="left" valign="top" class="classRowLabel"><strong>Poskod</strong></td>
      <td width="30" align="center" valign="top" class="classRowLabel"><span style="font-weight:bold">:</span></td>
      <td class="classRow"><input name="master_institusi[poskod]" value="<?=$institusi->poskod?>" type="text" id="master_institusi[]" onfocus="" onblur="" onselect="" onchange="" size="5" maxlength="5" />      </td>
    </tr>

    <tr>
      <td class="classRowLabel" align="left" valign="top">&nbsp;</td>
      <td height="20" align="left" valign="top" class="classRowLabel">&nbsp;</td>
      <td align="center" valign="top" class="classRowLabel">&nbsp;</td>
      <td class="classRow">&nbsp;</td>
    </tr>
    <tr>
      <td class="classRowLabel" align="left" valign="top" width="10"><span style="color:red;">*</span></td>
      <td width="27%" height="20" align="left" valign="top" class="classRowLabel"><strong>Agensi Pelaksana </strong></td>
      <td width="30" align="center" valign="top" class="classRowLabel"><span style="font-weight:bold">:</span></td>
      <td class="classRow"><select name="master_institusi[agensi_pelaksana_id]" id="agensi_pelaksana_id">
        <?
				$combo   = new GUI();
				$options = getOptionsFromTable('ref_agensi_pelaksana','id','agensi_pelaksana');
				echo $combo->printCombo2($options, "",true, "$institusi->agensi_pelaksana_id",false,0);
			  ?>
      </select></td>
    </tr>
    <tr>
      <td class="classRowLabel" align="left" valign="top" width="10"><span style="color:red;">*</span></td>
      <td width="27%" height="20" align="left" valign="top" class="classRowLabel"><strong>Lokasi</strong></td>
      <td width="30" align="center" valign="top" class="classRowLabel"><span style="font-weight:bold">:</span></td>
      <td class="classRow"><select name="master_institusi[lokasi_id]" id="lokasi_id">
        <?
				$combo   = new GUI();
				$options = getOptionsFromTable('ref_lokasi','id','lokasi');
				echo $combo->printCombo2($options, "lokasi",true, "$institusi->lokasi_id",false,0);
			  ?>
      </select></td>
    </tr>
    <tr>
      <td class="classRowLabel" align="left" valign="top">&nbsp;</td>
      <td height="20" align="left" valign="top" class="classRowLabel">&nbsp;</td>
      <td align="center" valign="top" class="classRowLabel">&nbsp;</td>
      <td class="classRow">&nbsp;</td>
    </tr>
    <tr>
      <td class="classRowLabel" align="left" valign="top" width="10"><span style="color:red;">*</span></td>
      <td width="27%" height="20" align="left" valign="top" class="classRowLabel"><strong>Negeri</strong></td>
      <td width="30" align="center" valign="top" class="classRowLabel"><span style="font-weight:bold">:</span></td>
      <td class="classRow"><select name="master_institusi[negeri_id]" id="negeri_id" onchange="getAjaxParlimen();getAjaxDaerah();getAjaxPPD();">
        <?
				$combo   = new GUI();
				$options = getOptionsFromTable('ref_negeri','id','negeri');
				echo $combo->printCombo2($options, "pisang",true, "$institusi->negeri_id",false,0);
			  ?>
      </select></td>
    </tr>
    
    <tr>
      <td class="classRowLabel" align="left" valign="top" width="10"><span style="color:red;">*</span></td>
      <td width="27%" height="20" align="left" valign="top" class="classRowLabel"><strong>Daerah</strong></td>
      <td width="30" align="center" valign="top" class="classRowLabel"><span style="font-weight:bold">:</span></td>
      <td class="classRow"><span id="select_daerah_span"><select name="master_institusi[kod_daerah]" id="kod_daerah">
        <?
				$combo   = new GUI();
				$options = getOptionsFromTable('ref_daerah','kod_daerah','daerah');
				echo $combo->printCombo2($options, "",true, "$institusi->kod_daerah",false,0);
			  ?>
      </select></span></td>
    </tr>
    <tr>
      <td class="classRowLabel" align="left" valign="top" width="10"><span style="color:red;">*</span></td>
      <td width="27%" height="20" align="left" valign="top" class="classRowLabel"><strong>PPD</strong></td>
      <td width="30" align="center" valign="top" class="classRowLabel"><span style="font-weight:bold">:</span></td>
      <td class="classRow"><span id="select_ppd_span"><select name="master_institusi[kod_ppd]" id="kod_ppd" onchange="">
        <?
				$combo   = new GUI();
				$options = getOptionsFromTable('ref_ppd','kod_ppd','ppd');
				echo $combo->printCombo2($options, "pisang",true, "$institusi->kod_ppd",false,0);
			  ?>
      </select></span></td>
    </tr>
    <tr>
      <td class="classRowLabel" align="left" valign="top" width="10"><span style="color:red;">*</span></td>
      <td width="27%" height="20" align="left" valign="top" class="classRowLabel"><strong>Parlimen</strong></td>
      <td width="30" align="center" valign="top" class="classRowLabel"><span style="font-weight:bold">:</span></td>
      <td class="classRow"><span id="select_parlimen_span"><select name="master_institusi[parlimen_id]" id="parlimen_id" onchange="getAjaxDun();">
        <?
				$combo   = new GUI();
				$options = getOptionsFromTable('ref_parlimen','id','parlimen');
				echo $combo->printCombo2($options, "",true, "$institusi->parlimen_id",false,0);
			  ?>
      </select></span></td>
    </tr>
    <tr>
      <td class="classRowLabel" align="left" valign="top" width="10"><span style="color:red;">*</span></td>
      <td width="27%" height="20" align="left" valign="top" class="classRowLabel"><strong>Dewan Undangan Negeri(DUN) </strong></td>
      <td width="30" align="center" valign="top" class="classRowLabel"><span style="font-weight:bold">:</span></td>
      <td class="classRow"><span id="select_dun_span"><select name="master_institusi[dun_id]" id="dun_id" onchange="">
        <?
				$combo   = new GUI();
				$options = getOptionsFromTable('ref_dun','id','dun');
				echo $combo->printCombo2($options, "",true, "$institusi->dun_id",false,0);
			  ?>
      </select></span></td>
    </tr>
    <tr>
      <td class="classRowLabel" align="left" valign="top">&nbsp;</td>
      <td height="20" align="left" valign="top" class="classRowLabel">&nbsp;</td>
      <td align="center" valign="top" class="classRowLabel">&nbsp;</td>
      <td class="classRow">&nbsp;</td>
    </tr>
    <tr>
      <td class="classRowLabel" align="left" valign="top" width="10"><span style="color:red;">*</span></td>
      <td width="27%" height="20" align="left" valign="top" class="classRowLabel"><strong>Bahasa Pengantar </strong></td>
      <td width="30" align="center" valign="top" class="classRowLabel"><span style="font-weight:bold">:</span></td>
      <td class="classRow"><select name="master_institusi[bahasa_penghantar_id]" id="bahasa_penghantar_id"">
        <?
				$combo   = new GUI();
				$options = getOptionsFromTable('ref_bahasa_penghantar','id','bahasa');
				echo $combo->printCombo2($options, "",true, "$institusi->bahasa_penghantar_id",false,0);
			  ?>
      </select></td>
    </tr>
    <tr>
      <td class="classRowLabel" align="left" valign="top" width="10"><span style="color:red;">*</span></td>
      <td width="27%" height="20" align="left" valign="top" class="classRowLabel"><strong>Gred Institusi</strong></td>
      <td width="30" align="center" valign="top" class="classRowLabel"><span style="font-weight:bold">:</span></td>
      <td class="classRow"><select name="master_institusi[gred_institusi_id]" id="gred_institusi_id" onchange="">
        <?
				$combo   = new GUI();
				$options = getOptionsFromTable('ref_gred_institusi','id','gred_institusi');
				echo $combo->printCombo2($options, "",true, "$institusi->gred_institusi_id",false,0);
			  ?>
      </select></td>
    </tr>
    <tr>
      <td class="classRowLabel" align="left" valign="top" width="10">&nbsp;</td>
      <td width="27%" height="20" align="left" valign="top" class="classRowLabel"><strong>Laman Web </strong></td>
      <td width="30" align="center" valign="top" class="classRowLabel"><span style="font-weight:bold">:</span></td>
      <td class="classRow"><input name="master_institusi[url]" value="<?=$institusi->url?>" type="text" id="master_institusi[]" onfocus="" onblur="" onselect="" onchange="" size="50" maxlength="80" />      </td>
    </tr>
    <tr>
      <td class="classRowLabel" align="left" valign="top" width="10">&nbsp;</td>
      <td width="27%" height="20" align="left" valign="top" class="classRowLabel"><strong>Email </strong></td>
      <td width="30" align="center" valign="top" class="classRowLabel"><span style="font-weight:bold">:</span></td>
      <td class="classRow"><input name="master_institusi[email]" value="<?=$institusi->email?>" type="text" id="master_institusi[]" onfocus="" onblur="" onselect="" onchange="" size="50" maxlength="30" />      </td>
    </tr>
    <tr>
      <td class="classRowLabel" align="left" valign="top" width="10"><span style="color:red;">*</span></td>
      <td width="27%" height="20" align="left" valign="top" class="classRowLabel"><strong>Jenis Institusi </strong></td>
      <td width="30" align="center" valign="top" class="classRowLabel"><span style="font-weight:bold">:</span></td>
      <td class="classRow"><select name="master_institusi[jenis_institusi_id]" id="jenis_institusi_id">
        <?
				$combo   = new GUI();
				$options = getOptionsFromTable('ref_jenis_institusi','id','jenis_institusi');
				//$options = getOptionsFromTableWithConds('ref_jenis_institusi','id','jenis_institusi',"WHERE id in('18','30','31')");
				echo $combo->printCombo2($options, "pisang",true, "$institusi->jenis_institusi_id",false,0);
			  ?>
      </select></td>
    </tr>
    <tr>
      <td class="classRowLabel" align="left" valign="top" width="10">&nbsp;</td>
      <td width="27%" height="20" align="left" valign="top" class="classRowLabel"><strong>Tarikh Ditubuhkan </strong></td>
      <td width="30" align="center" valign="top" class="classRowLabel"><span style="font-weight:bold">:</span></td>
      <td class="classRow"><input name="master_institusi[tarikh_tubuh]" value="<?=$institusi->tarikh_tubuh?>" onblur="" onchange="" onfocus="" onselect="" maxlength="" size="20" type="text" />
        (dd-mm-yyyy)      </td>
    </tr>
    <tr>
      <td class="classRowLabel" align="left" valign="top" width="10">&nbsp;</td>
      <td width="27%" height="20" align="left" valign="top" class="classRowLabel"><strong>Tadika </strong></td>
      <td width="30" align="center" valign="top" class="classRowLabel"><span style="font-weight:bold">:</span></td>
      <td class="classRow"><input name="master_institusi[prasekolah]" type="radio" value="t" <? echo ($institusi->prasekolah=='t')? "checked":"";?>/>
        Ada 
        <input name="master_institusi[prasekolah]" type="radio" value="f" <? echo ($institusi->prasekolah=='f')? "checked":"";?>/>
        Tiada</td>
    </tr>
    <tr>
      <td class="classRowLabel" align="left" valign="top" width="10">&nbsp;</td>
      <td width="27%" height="20" align="left" valign="top" class="classRowLabel"><strong>Aktif </strong></td>
      <td width="30" align="center" valign="top" class="classRowLabel"><span style="font-weight:bold">:</span></td>
      <td class="classRow"><input name="master_institusi[aktif]" type="radio" value="t"  <? echo ($institusi->aktif=='t')? "checked":"";?> />
      Ya       
      <input name="master_institusi[aktif]" type="radio" value="f"  <? echo ($institusi->aktif=='f')? "checked":"";?> />
      Tidak</td>
    </tr>
    <tr>
      <td class="classRowLabel" align="left" valign="top" width="10"><span style="color:red;">*</span></td>
      <td width="27%" height="20" align="left" valign="top" class="classRowLabel"><strong>Maklumat OKU</strong></td>
      <td width="30" align="center" valign="top" class="classRowLabel"><span style="font-weight:bold">:</span></td>
      <td class="classRow"><select name="master_institusi[maklumat_oku_id]" id="maklumat_oku_id">
        <?
				$combo   = new GUI();
				$options = getOptionsFromTable('ref_maklumat_oku','id','maklumat_oku');
				echo $combo->printCombo2($options, "",true, "$institusi->maklumat_oku_id",false,0);
			  ?>
      </select></td>
    </tr>
    <tr>
      <td align="left" class="classRow"></td>
      <td align="left" class="classRow"></td>
      <td align="center" class="classRow"></td>
      <td class="classRow">&nbsp;</td>
    </tr>
    <tr>
      <td width="10" align="left" class="classRow"></td>
      <td align="left" class="classRow"></td>
      <td width="30" align="center" class="classRow"></td>
      <td class="classRow"><span class="TableRowLeft">
        <!--input name="button2" type="submit" class="Button" onclick="" value="Simpan" style=" width:100px;" /-->
        <input name="button2" type="button" class="Button" onclick="location='?act=new_sek_swasta_step3'" value="Simpan" style=" width:100px;" />
      </span><span class="TableRowLeft">
      <input name="button22" type="submit" class="Button" onclick="" value="Batal" style=" width:100px;" />
      </span></td>
    </tr>
  </tbody>
</table>

</fieldset>

<script>

function GoSubmit(df) {

	//if (!checkSelection(strRegExp,$('kod'),'Kod Institusi')) return false;
	if (!checkInput(/.*/,$('kod'),'Kod Institusi')) return false;
	if (!checkInput(/.*/,$('nama'),'Nama Institusi')) return false;
	if (!checkInput(/.*/,$('alamat'),'Alamat Institusi')) return false;

	if (!checkSelection(strRegExp,$('agensi_pelaksana_id'),'Agensi Pelaksana')) return false;
	if (!checkSelection(strRegExp,$('negeri_id'),'Negeri')) return false;
	if (!checkSelection(strRegExp,$('lokasi_id'),'Lokasi')) return false;
	if (!checkSelection(strRegExp,$('kod_daerah'),'Daerah')) return false;

	if (!checkSelection(strRegExp,$('kod_ppd'),'PPD')) return false;
	if (!checkSelection(strRegExp,$('parlimen_id'),'Parlimen')) return false;
	if (!checkSelection(strRegExp,$('dun_id'),'DUN')) return false;
	if (!checkSelection(strRegExp,$('bahasa_penghantar_id'),'Bahasa Penghantar')) return false;
	if (!checkSelection(strRegExp,$('gred_institusi_id'),'Gred Insitusi')) return false;
	if (!checkSelection(strRegExp,$('jenis_institusi_id'),'Jenis Insitusi')) return false;
	if (!checkSelection(strRegExp,$('maklumat_oku_id'),'Maklumat OKU')) return false;

	//if (!checkInput(anythingRegExp,$('profile_name'),'Nama Penuh Pemohon')) return false;
	//if (!checkInput(anything,$('profile_fax'),'Nombor Fax')) return false;

	return true;
}

</script>

<script>
function getAjaxPPD() {
	//$('select_ppd_span').innerHTML = "<font color=orange>Searching PPD...please wait</font>"
	ajax_department_request("ajax.php?act=ppds_of_negeri", "negeri_id="+$("negeri_id").value)
}

function ajax_department_request(url, data) {
    var myAjax = new Ajax.Request(
        url,
        {method: 'post', parameters: data, onComplete: ajax_department_response}
    );
}

function ajax_department_response(originalRequest) {
	if (originalRequest.responseText != 0) {
		var a = originalRequest.responseText.split("$$")
		var k = new Array(a.length)
		for (i=0; i<k.length; i++) {
			k[i] = a[i].split("=")
		}
		//alert(originalRequest.responseText)
		
		str  = "<select  id=\"kod_ppd\" name=\"master_institusi[kod_ppd]\" class=\"px200\">\n";
		str += "<option value=\"\">Sila Pilih</option>\n"
		for (i=0; i<k.length; i++) {
			str += "<option value=\"" + k[i][1] + "\">" + k[i][0] + "</option>\n";
		}
		str += "</select>\n";
		$("select_ppd_span").innerHTML = str;
	}
	else {
		$('select_ppd_span').innerHTML = "<font color=orange>List not found</font>"
	}
}

function getAjaxDaerah() {
	//$('select_daerah_span').innerHTML = "<font color=orange>Searching Daerah...please wait</font>"
	ajax_daerah_request("ajax.php?act=daerahs_of_negeri", "negeri_id="+$("negeri_id").value)
}

function ajax_daerah_request(url, data) {
    var myAjax = new Ajax.Request(
        url,
        {method: 'post', parameters: data, onComplete: ajax_daerah_response}
    );
}

function ajax_daerah_response(originalRequest) {
	if (originalRequest.responseText != 0) {
		var a = originalRequest.responseText.split("$$")
		var k = new Array(a.length)
		for (i=0; i<k.length; i++) {
			k[i] = a[i].split("=")
		}
		//alert(originalRequest.responseText)
		
		str  = "<select  id=\"kod_daerah\" name=\"master_institusi[kod_daerah]\" class=\"px200\">\n";
		str += "<option value=\"\">Sila Pilih</option>\n"
		for (i=0; i<k.length; i++) {
			str += "<option value=\"" + k[i][1] + "\">" + k[i][0] + "</option>\n";
		}
		str += "</select>\n";
		$("select_daerah_span").innerHTML = str;
	}
	else {
		$('select_daerah_span').innerHTML = "<font color=orange>List not found</font>"
	}
}


function getAjaxParlimen() {
	//$('select_parlimen_span').innerHTML = "<font color=orange>Searching Parlimen...please wait</font>"
	ajax_parlimen_request("ajax.php?act=parlimens_of_negeri", "negeri_id="+$("negeri_id").value)
}

function ajax_parlimen_request(url, data) {
    var myAjax = new Ajax.Request(
        url,
        {method: 'post', parameters: data, onComplete: ajax_parlimen_response}
    );
}

function ajax_parlimen_response(originalRequest) {
	if (originalRequest.responseText != 0) {
		var a = originalRequest.responseText.split("$$")
		var k = new Array(a.length)
		for (i=0; i<k.length; i++) {
			k[i] = a[i].split("=")
		}
		//alert(originalRequest.responseText)
		
		str  = "<select  id=\"parlimen_id\" name=\"master_institusi[parlimen_id]\" class=\"px200\" onchange=\"getAjaxDun()\">\n";
		str += "<option value=\"\">Sila Pilih</option>\n"
		for (i=0; i<k.length; i++) {
			str += "<option value=\"" + k[i][1] + "\">" + k[i][0] + "</option>\n";
		}
		str += "</select>\n";
		$("select_parlimen_span").innerHTML = str;
	}
	else {
		$('select_parlimen_span').innerHTML = "<font color=orange>List not found</font>"
	}
}

function getAjaxDun() {
	//$('select_parlimen_span').innerHTML = "<font color=orange>Searching Parlimen...please wait</font>"
	ajax_dun_request("ajax.php?act=duns_of_parlimen", "parlimen_id="+$("parlimen_id").value)
}

function ajax_dun_request(url, data) {
    var myAjax = new Ajax.Request(
        url,
        {method: 'post', parameters: data, onComplete: ajax_dun_response}
    );
}

function ajax_dun_response(originalRequest) {
	if (originalRequest.responseText != 0) {
		var a = originalRequest.responseText.split("$$")
		var k = new Array(a.length)
		for (i=0; i<k.length; i++) {
			k[i] = a[i].split("=")
		}
		//alert(originalRequest.responseText)
		
		str  = "<select  id=\"dun_id\" name=\"master_institusi[dun_id]\" class=\"px200\">\n";
		str += "<option value=\"\">Sila Pilih</option>\n"
		for (i=0; i<k.length; i++) {
			str += "<option value=\"" + k[i][1] + "\">" + k[i][0] + "</option>\n";
		}
		str += "</select>\n";
		$("select_dun_span").innerHTML = str;
	}
	else {
		$('select_dun_span').innerHTML = "<font color=orange>List not found</font>"
	}
}

</script>
